var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2BundleManager = require("BundleManager");
var $2DataManager = require("DataManager");
var $2PlantMgr = require("PlantMgr");
var $2UIManager = require("UIManager");
var $2SceneStage = require("SceneStage");
var $2MyUtils = require("MyUtils");
var $2BallPanelUI = require("BallPanelUI");
var h = cc._decorator.ccclass;
var def_Ball = /* */function (_cc$Component4) {
  babel_inherits(u, _cc$Component4);
  var _super4 = babel_createSuper(u);
  function u() {
    babel_classCallCheck(this, u);
    return _super4.apply(this, arguments);
  }
  babel_createClass(u, [{
    key: "init",
    value: function init(e) {
      var _this9 = this;
      this.plantId = e;
      this.node.getComponentInChildren(sp.Skeleton).skeletonData = $2BundleManager.default.instance.getBundleRes("Spine", "plant/" + $2PlantMgr.default.instance().getPlant(this.plantId).dragonName + "/" + $2PlantMgr.default.instance().getPlant(this.plantId).dragonName, sp.SkeletonData);
      this.node.getComponentInChildren(sp.Skeleton).setAnimation(0, "daiji", true);
      var t = new cc.Vec2($2MyUtils.MyUtils.getRandomInt(-800, 0), 440);
      var a = new cc.Vec2($2MyUtils.MyUtils.getRandomInt(-700, 700), $2MyUtils.MyUtils.getRandomInt(-400, 400));
      var n = new cc.Vec2($2MyUtils.MyUtils.getRandomInt(-400, 0), -440);
      var s = new cc.Vec2($2MyUtils.MyUtils.getRandomInt(-700, 700), $2MyUtils.MyUtils.getRandomInt(-400, 400));
      var l = new cc.Vec2($2MyUtils.MyUtils.getRandomInt(0, 800), 500);
      this.node.setPosition(t);
      cc.tween(this.node).bezierTo(10, t, a, n).bezierTo(10, n, s, l).call(function () {
        _this9.node.destroy();
      }).start();
    }
  }, {
    key: "onClick",
    value: function onClick() {
      if ($2DataManager.default.instance.selectPlantID.includes(this.plantId)) {
        $2UIManager.default.instance.showToast("已使用该植物!!!");
      } else if (0 != $2DataManager.default.instance.level) {
        $2UIManager.default.instance.openUI("BallPanelUI").getComponent($2BallPanelUI.default).init(this.plantId, this);
      } else {
        this.getReward();
      }
    }
  }, {
    key: "getReward",
    value: function getReward() {
      var _this10 = this;
      $2DataManager.default.instance.selectPlantID.push(this.plantId);
      this.node.getChildByName("Circle").active = false;
      this.node.getChildByName("video").active = false;
      this.node.getChildByName("ballTitle").active = false;
      $2DataManager.default.instance.tryPlant.includes(this.plantId) || $2DataManager.default.instance.tryPlant.push(this.plantId);
      $2SceneStage.default.instance.showDeck(true);
      var e = $2SceneStage.default.instance.cardPanel.childrenCount;
      $2SceneStage.default.instance.cardPanel.children[e - 1].active = false;
      cc.Tween.stopAllByTarget(this.node);
      cc.tween(this.node).to(1, {
        x: $2SceneStage.default.instance.cardPanel.children[e - 1].x - this.node.parent.x + $2SceneStage.default.instance.cardPanel.x,
        y: $2SceneStage.default.instance.cardPanel.children[e - 1].y - this.node.parent.y + $2SceneStage.default.instance.cardPanel.y
      }).call(function () {
        _this10.node.destroy();
        $2SceneStage.default.instance.cardPanel.children[e - 1].active = true;
      }).start();
    }
  }]);
  return u;
}(cc.Component);
def_Ball = cc__decorate([h], def_Ball);
exports.default = def_Ball;